<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // 对数组的解构
    // let {name,age} = {name:'马宇航',age:'20'}
    let { name: abb, age: ccc } = { name: '马宇航', age: '20' }
    // console.log(abb);//马宇航
    // ...剩余运算符:只能写在最后
    let { name: abc, ...age } = { name: '马宇航', age: '20', sex: 1 }
    // console.log(age);
    //嵌套 可忽略(忽略的是数组) {name:'asdf',girlFriends:{name:'acb',age:18}}
    let { name, girlFriends: [, { name: ff, age: dd, sex1 }] } = { name: 'asdf', girlFriends: ['girl', { name: 'acb', age: 18, sex: 0 }] }
    // console.log(name);//asdf
    // console.log(ff);//acb
    // console.log(dd);//18
    //不完全解构 {pa:[{yy:'word'}]}
    let aa = {
      name: 'asdf',girlFriends:['girl',
        { name: 'acb', age: 18, sex: 0 },
        {
          cc: 'abc', ff:[{ aa: 'bb', cc: 'dd' }]
      }
      ]
    }
    console.log(aa.girlFriends[1].name);//acb
    
    let { pa: [y, x = 1] } = { pa: [{ yy: 'word' }] }
    console.log(y);//
    console.log(x);//1

  </script>
</body>

</html>